package cn.leelei.springdata.repository;

import java.util.List;

import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
/*不分頁 import org.springframework.data.repository.CrudRepository;*/
/*分頁import org.springframework.data.repository.PagingAndSortingRepository;*/
import org.springframework.data.repository.PagingAndSortingRepository;
import org.springframework.transaction.annotation.Transactional;

import cn.leelei.springdata.entity.User;

/**
 * 数据持久层
 * 
 * @author Administrator 1.不分頁只做crud操作CrudRepository
 *         2.分頁PagingAndSortingRepository
 */
public interface UserRepository extends PagingAndSortingRepository<User, Integer> {

	List<User> findUserByUserName(String userName);

	@Query("from User where userName like %?1")
	List<User> findUserByUser(String userName);

	@Transactional
	@Modifying
	@Query("update User set userName=?1 where id=?2")
	void updateUserByUser(String userName, Integer id);

}
